package com.okamura.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.okamura.domain.PostListInfo;
import com.okamura.mapper.PostListInfoMapper;
import com.okamura.service.IPostListInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PostListInfoServiceImpl implements IPostListInfoService {
    @Autowired
    private PostListInfoMapper postListInfoMapper;
    @Override
    public PostListInfo getPostInfo() {
        //创建queryWrapper对象
        QueryWrapper<PostListInfo> postQueryWrapper = new QueryWrapper<>();
        postQueryWrapper.select("TOP 1 post_id,cont_no,msg_type,post_msg,ack_msg,post_st,create_time,update_time,comments");
        postQueryWrapper.eq("POST_ST",0).last(""); //状态为初始的信息
        return postListInfoMapper.selectOne(postQueryWrapper);
    }

    @Override
    public PostListInfo getPostInfoById(Long postId) {
        return postListInfoMapper.selectById(postId);
    }

    @Override
    public int updatePostInfo(PostListInfo postInfo) {
        return postListInfoMapper.updateById(postInfo);
    }

    @Override
    public int updatePostInfo() {
        return 0;
    }
}
